<template>
	<view class="zongbox" style="width: 750upx;height: 100vh;">
		<u-navbar id="navbar" :is-back="true" back-icon-color="#FFFFFF" :back-text-style="backstyle"
			title-color="#FFFFFF" back-text="添加会员" :background="background">
		</u-navbar>

		<view class="head-box">
			<view class="center-box">
				<view class="all-text-box">
					<view class="head-img-boxs">
						<u-lazy-load border-radius="65" height="130" img-mode="aspectFill" :image="imgUrl">
						</u-lazy-load>
					</view>

					<view class="titles-text">
						{{name}}
					</view>
					<view class="slogan-text">
						邀您开启健康管理新生活
					</view>
					<view class="enjoy-text">
						享受特权
					</view>
					<!-- 特权介绍 -->
					<view class="privilege-box">
						<view class="privilege-list" v-for="(item,index) in askList" :key="index">
							<view class="privilege-img">
								<image :src="item.image" style="width: 122upx;height: 122upx;border-radius: 50%;"
									mode=""></image>
							</view>
							<view class="privilege-text">
								{{item.title}}
							</view>
						</view>
					</view>
					<button :disabled="disabled" class="invite-but" @tap="bindMemberByInviteCode(code)">
						我要加入
					</button>
				</view>

			</view>
		</view>



	</view>
</template>

<script>

import uNavbar from "@/uview-ui/components/u-navbar/u-navbar.vue"

import uLazyLoad from "@/uview-ui/components/u-lazy-load/u-lazy-load.vue"

	export default {
		components: {
			uNavbar,
			uLazyLoad,

		},
		data() {
			return {
				disabled:false,//禁用button
				imgUrl: '', //顾问头像
				name: '--', //顾问昵称
				askList: [{
						image: 'http://static.bsyjk.cn/wei1/9CEAF270E657400DB4B1677CF54D9EA1.png',
						title: '健康咨询'
					},
					{
						image: 'http://static.bsyjk.cn/wei2/EA54AA28F5D04291B4A2277644E72AB6.png',
						title: '贴心服务'
					},
					{
						image: 'http://static.bsyjk.cn/wei3/FAF70E9AE6134E2A8816FA4ECB3C62F9.png',
						title: '数据解读'
					},
					{
						image: 'http://static.bsyjk.cn/wei4/A8321F8ECE8A410A84420BDB4C469877.png',
						title: '健康跟踪'
					},
					{
						image: 'http://static.bsyjk.cn/wei3/FAF70E9AE6134E2A8816FA4ECB3C62F9.png',
						title: '饮食推荐'
					},
					{
						image: 'http://static.bsyjk.cn/wei6/62DF97AB0B004847B043026DCD03499D.png',
						title: '运动推荐'
					},
					{
						image: 'http://static.bsyjk.cn/wei7/2D03BBF843D44D1B883B68BA09BC2B70.png',
						title: '睡眠指导'
					},
					{
						image: 'http://static.bsyjk.cn/wei8/3A30C80AAD4A42DC92008308D2441167.png',
						title: '心理指导'
					}
				],

				background: {
					backgroundImage: 'linear-gradient(10deg, rgb(129, 192, 66,0), rgb(46, 167, 224,0))'
				},
				backstyle: {
					color: '#ffffff',
					'white-space': 'nowrap',
					'font-size': '36upx'
				},
				height: 0,
				send: false, //点击状态
				colro: '#666666',
				code: '', //绑定code
			};
		},
		onLoad(e) {
			// 头像昵称
			this.code = decodeURIComponent(e.a); 
			this.getCounselor(this.code);
		},
		methods: {
			getCounselor(code) {
				const id = code.split('-')[0]
				this.$https.get(global.apiUrls.getCounselorById, { adviserId: id }).then((res) => {
					if (res.data.code === 1000) {
						this.imgUrl = res.data.result.adviserAvatarUrl || 'https://static.bsyjk.cn/newoss/DF9EF2520B3549C794237D572FB27953.png';
						this.name = res.data.result.realName
					}
				})
			},
			bindMemberByInviteCode(code) {
				let fdata = {
						code: code,
						userId: uni.getStorageSync(global.IS_DEV?'USER_DATA_BSY_T':'USER_DATA_BSY_Z').userId
					},
					_this = this;
					_this.disabled = true;
				this.$api.post(global.apiUrls.bindMemberByInviteCode, fdata)
					.then(res => {
						if (res.data.code == 1000) {
							uni.showToast({
								title: res.data.message,
								duration: 2000
							});
							setTimeout(() => {
								uni.reLaunch({
									url: '/pages/tab/home',
								});
							}, 2000);
						} else {
							uni.showToast({
								title: res.data.message,
								icon: "none",
								duration: 2000
							});
						}
						_this.disabled = false;
					})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.title {
		color: #FFFFFF;
		font-size: 36upx;

	}

	.zongbox {
		background-image: url(https://bsyjk-pic.bsyjk.cn/l/353A78CB78994002870A577CEEB4635D.jpeg);
		background-size: 100% 100%;
		height: 100vh;
	}


	.head-box {
		padding: 1upx 0upx;


		.center-box {
			background-color: rgba(245, 187, 0, 0);
			width: 100%;


			.all-text-box {
				margin-top: 50upx;
				padding: 1upx;
				width: 700upx;
				min-height: 520upx;
				margin-left: 25upx;
				background-image: url(http://static.bsyjk.cn/yaoqingllod/42F6DB9565A745C3B065DFD7A19D30E5.png);
				background-size: 100% 100%;
				position: relative;

				//头像
				.head-img-boxs {
					width: 130upx;
					height: 130upx;
					border-radius: 50%;
					overflow: hidden;
					margin-top: 56upx;
					margin-left: 284upx;
				}

				.titles-text {
					font-size: 28upx;
					font-family: PingFang-SC-Heavy, PingFang-SC;
					font-weight: 800;
					color: #333333;
					width: 100%;
					text-align: center;
					margin-top: 22upx;
					// line-height: 67px;
				}

				.slogan-text {
					width: 100%;
					text-align: center;
					font-size: 38upx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #000000;
					margin-top: 32upx;
				}

				.enjoy-text {
					width: 100%;
					text-align: center;
					font-size: 28upx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: bold;
					color: #F56767;
					margin-top: 20upx;
				}

				//特权介绍
				.privilege-box {
					padding: 0upx 60upx;
					display: flex;
					justify-content: space-between;
					align-items: center;
					flex-wrap: wrap;

					.privilege-list {
						display: flex;
						flex-direction: column;
						align-items: center;
						margin-top: 30upx;

						.privilege-img {
							width: 122upx;
							height: 122upx;
							border-radius: 50%;
							overflow: hidden;
						}

						.privilege-text {
							height: 34upx;
							font-size: 24upx;
							font-family: PingFang-SC-Heavy, PingFang-SC;
							font-weight: 800;
							color: #333333;
						}
					}
				}

				.invite-but {
					width: 600upx;
					height: 90upx;
					line-height: 90upx;
					text-align: center;
					color: #FFFFFF;
					font-size: 34upx;
					// background: linear-gradient(112deg, #81C042 0%, #2EA7E0 100%);
					background: url(https://bsyjk-pic.bsyjk.cn/toprbg/10099E8526734AC383D6ADEED897F016.png)no-repeat;
					background-size: 750upx 375upx;
					border-radius: 45upx;
					margin-left: 50upx;
					margin-top: 50upx;
					margin-bottom: 50upx;
				}
			}
		}

	}
</style>
